//构建地图坐标
function buildMap() {
	//初始化
	var dom = $('#mapBackgroundDiv');
	dom.html('');
	var str = '';
	//区域蒙版
	for(var y = 0 ; y < 12 ; y ++){
		for(var x = 0 ; x < 12 ; x ++){
			str =  str + '<div onclick="mapMove(\'' + x + '\',\'' + y + '\')" class="mapbox" id="mapbox_' + x + '_' + y + '">' + x + '_' + y + '</div>';
		}
	}	
	console.log(str);
	dom.append(str);
	
	showMapAreaName('当前地图');
}
////////////////////////////////////////////////当前操作区域信息///////////////////////////////////////////////
var currentMapID;
var currentMapName;
var currentMapXNum;
var currentMapYNum;
//地图加载
function showMapHome(mapId){
	currentMapID = mapId;
	//加载庄园配置
	gameMapAreaDetailList(currentMapID);
	//展示庄园背景
	changeMap(currentMapID);
}
//更换地图配置
function changeMap(mapId){
	//这里需要延时加载
	if(checkEmpty(nsgs_system_map_map)){
		//展示庄园背景
		setTimeout(function(){ 
			changeMap(mapId);
		}, 2000);
		return;
	}
	//获得区域配置信息
	var move_map = nsgs_system_map_map.get(mapId);
	if(checkEmpty(nsgs_system_map_map)){
		//无实际配置区域
		return;
	}
	//展示地图背景
	$("#mapBackgroundDiv").css("background-image", "url(" + move_map.mapPicUrl + ")");
	//展示地图名称
	showMapAreaName(move_map.mapName);
}
//展示区域名称
function showMapAreaName(name){
	var dom = $('#cruuentAreaNameTD');
	dom.html('');
	var str = '<h3>'+ name +'</h3>';
	console.log(str);
	dom.append(str);
}
//地图区域移动
function mapMove(x,y){
	//当前区域配置
	var move_map_item = current_game_map_detail_map.get(currentMapID + x + y);
	//判断是否为地图传送点
	if(move_map_item.isSend == '1'){
		//进入新的地图
		currentMapID = move_map_item.nextMapId;
		currentMapXNum = move_map_item.nextXNum;
		currentMapYNum = move_map_item.nextYNum;
		//加载新的地图数据
		gameMapAreaDetailList(currentMapID);
	}else{
		currentMapXNum = move_map_item.xNum;
		currentMapYNum = move_map_item.yNum;
	}
	
	//刷新地图
	{
		//展示区域名称
		showMapAreaName(move_map_item.areaName);
		//加载当前区域玩家
		gameMapAreaPlayerList(currentMapID, currentMapXNum, currentMapYNum);
		//加载当前区域怪物
		gameMapAreaMonsterList(currentMapID, currentMapXNum, currentMapYNum);
	}
}
///////////////////////////////////////////////////////////////////////////////////////////////